package me.tuyou.activiti.taskService;

import me.tuyou.activiti.Base;
import org.activiti.engine.task.Task;
import org.junit.Test;

public class ExcludeGatewayTest extends Base {

    @Test
    public void deploy() {
        repositoryService.createDeployment().addClasspathResource("ExcludeGatewayTest.bpmn").name("排他网关测试").deploy();
    }

    /**
     * 发起申请
     */
    @Test
    public void startInstance() {
        runtimeService.startProcessInstanceByKey("ExcludeGatewayTest");
        Task task = taskService.createTaskQuery().taskAssignee("xiaoer").singleResult();
//        taskService.setVariable(task.getId(), "money", 100);
//        taskService.setVariable(task.getId(), "money", 800);
        taskService.setVariable(task.getId(), "money", 1500);
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 财务审批
     */
    @Test
    public void financeAudit() {
        Task task = taskService.createTaskQuery().taskAssignee("lanlan").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 部门经理审批
     */
    @Test
    public void deptManagerAudit() {
        Task task = taskService.createTaskQuery().taskAssignee("tuyou").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 总经理审批
     */
    @Test
    public void generalManagerAudit() {
        Task task = taskService.createTaskQuery().taskAssignee("yangrui").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }
}
